<?=form_open_multipart(uri_string())?>    
    <table class="form">
        <tr>
            <td class="required label" style="width: 150px;"><?=lang('full_name');?></td>
            <td><input type="text" name="fullname" id="fullname"class="w250" value="<?=$rs->fullname;?>"></td>
        </tr> 
            <tr>
            <td class="required label" style="width: 150px;"><?=lang('nick_name');?></td>
            <td><input type="text" name="username" id="username"class="w250" value="<?=$rs->username;?>"></td>
        </tr> 
        <tr>
            <td class="required label" style="width: 150px;"><?=lang('email');?></td>
            <td><input type="text" name="lb_email" id="lb_email"class="w150" value="<?=$rs->lb_email;?>"></td>
        </tr>
        <tr>
            <td class="required label" style="width: 150px;"><?=lang('password');?></td>
            <td><input type="password" name="lb_password" id="lb_password"class="w150" value=""></td>
        </tr>
        <tr>
            <td class="label" style="width: 150px;"><?=lang('phone');?></td>
            <td><input type="text" name="nb_phone" id="nb_phone"class="w150" value="<?=$rs->nb_phone;?>"></td>
        </tr>
        <tr>
            <td class="label" style="width: 150px;"><?=lang('address');?></td>
            <td><input type="text" name="address" id="address"class="w350" value="<?=$rs->address;?>"></td>
        </tr>
        <tr>
            <td class="label">Ngày tham gia</td>
            <td><input type="text" readonly name="dt_create" id="dt_create" value="<?=date_mysql2vn($rs->dt_create);?>"></td>
        </tr>
        <tr>
            <td class="label">Đăng nhập lần cuối</td>
            <td><input type="text" readonly name="dt_login" id="dt_login" value="<?=date_mysql2vn($rs->dt_login)?>"></td>
        </tr>
        <tr>
            <td class="label" style="width: 150px;"><?=lang('website');?></td>
            <td><input type="text" name="lb_website" id="lb_website"class="w350" value="<?=$rs->lb_website;?>"></td>
        </tr>
        <tr>
            <td class="label" style="width: 150px;"><?=lang('yahoo');?></td>
            <td><input type="text" name="lb_yahoo" id="lb_yahoo"class="w350" value="<?=$rs->lb_yahoo;?>"></td>
        </tr>
        <tr>
            <td class="label" style="width: 150px;"><?=lang('skype');?></td>
            <td><input type="text" name="lb_skype" id="lb_skype"class="w350" value="<?=$rs->lb_skype;?>"></td>
        </tr>
        <tr>
            <td class="label" style="width: 150px;"><?=lang('msn');?></td>
            <td><input type="text" name="lb_msn" id="lb_msn" class="w350" value="<?=$rs->lb_msn;?>"></td>
        </tr>
        <tr>
            <td class="label"><?=lang('image');?></td>
            <td>
                <img width="135px" height="135px" alt="avatar" id="avatar_img" src="<?php echo base_url_site()."uploads/avatar/135/".($rs->lb_image!=''?$rs->lb_image:'default_avatar.jpg');?>"/>                 
            </td>
        </tr>
        <tr>
            <td class="label">&nbsp;</td>
            <td>

                <input type="button" id="upload_avatar" value="<?=lang('change_avatar');?>"/>&nbsp;&nbsp;Max file size 2 MB
                <input type="hidden" name="lb_image" id="lb_image" value="<?php echo $rs->lb_image; ?>"/>
                <input type="hidden" id="member_id" name="member_id" value="<?php echo $rs->member_id; ?>"/>         
                <div id="status_message"></div>
            </td>
        </tr> 
        <tr>
            <td class="label"><?=lang('active_deactive');?></td>
            <td><input type="checkbox" name="bl_active" id="bl_active" <?php if($rs->bl_active==1) echo 'checked'; ?> value="<?=$rs->bl_active;?>"  onclick="setCheckboxValue(this);"></td>
        </tr>
        <tr>
            <td colspan="2" align="center">
                <input type="submit" name="bt_submit" value="" class="capnhat">
            </td>
        </tr>  
    </table>
<?=form_close()?>
<script type="text/javascript" language="javascript">
	$(document).ready(function(){
        new AjaxUpload($('#upload_avatar'),{
            action:'<?php echo base_url();?>user/settings_upload_avatar',
            name: 'uploadfile',
            data: {
                member_id:$("#member_id").val(),
                lb_image:$('#lb_image').val()
            },onSubmit: function(file, ext){
                 if (! (ext && /^(jpg|png|jpeg|gif|)$/.test(ext))){
                    // extension is not allowed
                    $('#status_message').text('Allow JPG, PNG, JPEG, GIF');
                    return false;
                }
                $('#status_message').text('Uploading. Please wait ...');
            },onComplete: function(file, response){
                //On completion clear the status
                $('#status_message').text('');
                //Add uploaded file to list
                if(response!="error")
				{
					var data = $.parseJSON(response) ;
					//$("#avatar").html('<img src="' + site + 'uploads/100/' + data.img + '" width="100" height="100" />') ;
                    document.getElementById('avatar_img').src = '<?php echo base_url_site();?>uploads/avatar/135/'+data.img;
					$("#lb_image").val(data.img) ;

                }else{

                }
            }
        });
    });

</script>

